package org.awenlice.playerdailyshop.data;

import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.level.saveddata.SavedData;

public class CustomServerData extends SavedData {
    private Long nextRefreshTime = 0L; // 示例：存储一个整数值

    public Long getNextRefreshTime() {
        return nextRefreshTime;
    }

    public void setNextRefreshTime(Long nextRefreshTime) {
        this.nextRefreshTime = nextRefreshTime;
        setDirty(); // 标记数据为脏，需要保存
    }

    @Override
    public CompoundTag save(CompoundTag tag) {
        tag.putLong("nextRefreshTime", nextRefreshTime); // 将数据保存到 NBT
        return tag;
    }

    public static CustomServerData load(CompoundTag tag) {
        CustomServerData data = new CustomServerData();
        data.nextRefreshTime = tag.getLong("nextRefreshTime"); // 从 NBT 加载数据
        return data;
    }
}